#include <cstdio>
#include <vector>
using namespace std;
struct edge
{
    int v;
    int w;
};
const int MAXN = 501;
const int INF = 1000000000;
int d[MAXN];
int N; //结点数
bool visit[MAXN] = {false};
int num[MAXN] = {0}; //记录最短路径的个数
int num_rescue_teams[MAXN];
int num_teams_total[MAXN] = {0};
vector<edge> adj[MAXN];
void Dijkstra(int s)
{
    fill(d, d + MAXN, INF);
    d[s] = 0;
    num_teams_total[s] = num_rescue_teams[s];
    num[s] = 1;
    int min;
    int m;
    for (int i = 0; i < N; ++i)
    {
        min = INF;
        m = -1;
        for (int j = 0; j < N; ++j)
        {
            if (d[j] < min && false == visit[j])
            {
                m = j;
                min = d[j];
            }
        }
        if (-1 == m)
            return;
        visit[m] = true;
        for (int k = 0; k < adj[m].size(); ++k)
        {
            int v = adj[m][k].v;
            int w = adj[m][k].w;
            if (false == visit[v])
            {
                if (d[m] + w < d[v])
                { //找到更短的路径
                    d[v] = d[m] + w;
                    num[v] = num[m];
                    num_teams_total[v] = num_teams_total[m] + num_rescue_teams[v];
                }
                else if (d[m] + w == d[v])
                { //找到与当前最短路径长度相同的路径
                    num[v] += num[m];
                    if (num_teams_total[m] + num_rescue_teams[v] > num_teams_total[v])
                    { //team更多，更新
                        num_teams_total[v] = num_rescue_teams[v] + num_teams_total[m];
                    }
                }
            }
        }
    }
}
int main()
{
    int M, C1, C2;
    scanf("%d%d%d%d", &N, &M, &C1, &C2);
    for (int i = 0; i < N; ++i)
    {
        scanf("%d", num_rescue_teams + i);
    }
    for (int i = 0; i < M; ++i)
    { //读取关于图的信息，建立邻接表
        int v;
        edge edge_cur;
        scanf("%d%d%d", &v, &edge_cur.v, &edge_cur.w);
        adj[v].push_back(edge_cur);
        int vertex = edge_cur.v; //无向边，所以要分别输入
        edge_cur.v = v;
        adj[vertex].push_back(edge_cur);
    }
    Dijkstra(C1);
    printf("%d %d\n", num[C2], num_teams_total[C2]);
}